<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>midremot</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="miditempo.html" title="miditempo" />
    <link rel="next" href="min.html" title="min" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">midremot</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="miditempo.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="min.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="midremot"></a>
      <div class="titlepage"></div>
      <a id="Indexmidremot" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">midremot</span>
        </h2>
        <p>midremot — 
      An opcode which can be used to implement a remote midi orchestra. This opcode will send midi events from a source machine to one destination.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp125129024"></a>
        <h2>Description</h2>
        <p>
      With the <span class="emphasis"><em>midremot</em></span> and <a class="link" href="midglobal.html" title="midglobal"><em class="citetitle">midglobal</em></a> opcodes you are able to perform instruments on remote machines and control them from a master machine. The remote opcodes are implemented using the master/client model. All the machines involved contain the same orchestra but only the master machine contains the information of the midi score. During the performance the master machine sends the midi events to the clients. The <span class="emphasis"><em>midremot</em></span> opcode will send events from a source machine to one destination if you want to send events to many destinations (broadcast) use the <a class="link" href="midglobal.html" title="midglobal"><em class="citetitle">midglobal</em></a> opcode instead. These two opcodes can be used in combination.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp125133504"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>midremot</strong></span> idestination, isource, instrnum [,instrnum...] </pre>
      </div>
      <div class="refsect1">
        <a id="idp125135616"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>idestination</em></span>
      -- a string that is the intended host computer (e.g. 192.168.0.100). This is the destination host which receives the events from the given instrument.
    </p>
        <p>
      <span class="emphasis"><em>isource</em></span>
      -- a string that is the intended host computer (e.g. 192.168.0.100). This is the source host which generates the events of the given instrument and sends it to the address given by idestination.
    </p>
        <p>
      <span class="emphasis"><em>instrnum</em></span>
      -- a list of instrument numbers which will be played on the destination machine
    </p>
      </div>
      <div class="refsect1">
        <a id="idp125140192"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the midremot opcode. It uses the files <a class="ulink" href="examples/midremot.csd" target="_top"><em class="citetitle">insremot.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp125142048"></a>
          <p class="title">
            <strong>Example 508. Example of the insremot opcode.</strong>
          </p>
          <div class="example-contents">
            <p>The example shows a Bach fugue played on 4 remote computers. The master machine is named "192.168.1.100", client1 "192.168.1.101" and so on. Start the clients on each machine (they will be waiting to receive the events from the master machine) and then start the master. Here is the command on linux to start a client (csound -dm0 -odac -+rtaudio=alsa midremot.csd -+rtmidi=Null), and the command on the master machine will look like this (csound -dm0 -odac -+rtaudio=alsa midremot.csd -F midremot.mid).</p>
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in</span>
-odac           -iadc     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o midremot.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="ohdr">sr</span>	<span class="op">=</span> 44100
<span class="ohdr">kr</span>	<span class="op">=</span> 441
<span class="ohdr">ksmps</span>	<span class="op">=</span> 100
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="ohdr">massign</span> 1,1 
<span class="ohdr">massign</span> 2,2 
<span class="ohdr">massign</span> 3,3 
<span class="ohdr">massign</span> 4,4 
<span class="ohdr">massign</span> 5,5 

ga1 <span class="opc">init</span> 0
ga2 <span class="opc">init</span> 0

gi1	<span class="opc">sfload</span>	   "19Trumpet.sf2" 

gi2	<span class="opc">sfload</span>	   "01hpschd.sf2" 

gi3	<span class="opc">sfload</span>	   "07AcousticGuitar.sf2" 

gi4	<span class="opc">sfload</span>	   "22Bassoon.sf2" 

gitab	<span class="ohdr">ftgen</span>	1,0,1024,10,1

<span class="opc">midremot</span> "192.168.1.100", "192.168.1.101", 1
<span class="opc">midremot</span> "192.168.1.100", "192.168.1.102", 2
<span class="opc">midremot</span> "192.168.1.100", "192.168.1.103", 3

<span class="opc">midglobal</span> "192.168.1.100", 5


	<span class="oblock">instr</span> 1
	<span class="opc">sfpassign</span>	   0, gi1
ifreq	<span class="opc">cpsmidi</span>
iamp	<span class="opc">ampmidi</span> 10
inum	<span class="opc">notnum</span>
ivel	<span class="opc">veloc</span>
kamp	<span class="opc">linsegr</span>	1,1,1,.1,0
kfreq	<span class="opc">init</span>	1
a1,a2	<span class="opc">sfplay</span>	ivel,inum,kamp<span class="op">*</span>iamp,kfreq,0,0
	<span class="opc">outs</span>	a1,a2
<span class="opc">vincr</span> ga1, a1<span class="op">*</span>.5
<span class="opc">vincr</span> ga2, a2<span class="op">*</span>.5
	<span class="oblock">endin</span>

	<span class="oblock">instr</span> 2
	<span class="opc">sfpassign</span>	0,    gi2
ifreq	<span class="opc">cpsmidi</span>
iamp	<span class="opc">ampmidi</span> 15
inum	<span class="opc">notnum</span>
ivel	<span class="opc">veloc</span>
kamp	<span class="opc">linsegr</span>	1,1,1,.1,0
kfreq	<span class="opc">init</span>	1
a1,a2	<span class="opc">sfplay</span>	ivel,inum,kamp<span class="op">*</span>iamp,kfreq,0,0
	<span class="opc">outs</span>	a1,a2
<span class="opc">vincr</span> ga1, a1<span class="op">*</span>.4
<span class="opc">vincr</span> ga2, a2<span class="op">*</span>.4
	<span class="oblock">endin</span>

	<span class="oblock">instr</span> 3
	<span class="opc">sfpassign</span>	0,    gi3
ifreq	<span class="opc">cpsmidi</span>
iamp	<span class="opc">ampmidi</span> 10
inum	<span class="opc">notnum</span>
ivel	<span class="opc">veloc</span>
kamp	<span class="opc">linsegr</span>	1,1,1,.1,0
kfreq	<span class="opc">init</span>	1
a1,a2	<span class="opc">sfplay</span>	ivel,inum,kamp<span class="op">*</span>iamp,kfreq,0,0
	<span class="opc">outs</span>	a1,a2
<span class="opc">vincr</span> ga1, a1<span class="op">*</span>.5
<span class="opc">vincr</span> ga2, a2<span class="op">*</span>.5
	<span class="oblock">endin</span>

	<span class="oblock">instr</span> 4
	<span class="opc">sfpassign</span>	0,    gi4
ifreq	<span class="opc">cpsmidi</span>
iamp	<span class="opc">ampmidi</span> 15
inum	<span class="opc">notnum</span>
ivel	<span class="opc">veloc</span>
kamp	<span class="opc">linsegr</span>	1,1,1,.1,0
kfreq	<span class="opc">init</span>	1
a1,a2	<span class="opc">sfplay</span>	ivel,inum,kamp<span class="op">*</span>iamp,kfreq,0,0
	<span class="opc">outs</span>	a1,a2
<span class="opc">vincr</span> ga1, a1<span class="op">*</span>.5
<span class="opc">vincr</span> ga2, a2<span class="op">*</span>.5
	<span class="oblock">endin</span>

<span class="oblock">instr</span>	5
      kamp <span class="opc">midic7</span> 1,0,1	
      <span class="opc">denorm</span> ga1
      <span class="opc">denorm</span> ga2
aL, aR  <span class="opc">reverbsc</span> ga1, ga2, .9, 16000, sr, 0.5
        <span class="opc">outs</span> aL, aR
	ga1	<span class="op">=</span>	0
     ga2   <span class="op">=</span>     0
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; Score</span>
<span class="stamnt">f</span>0  160
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp125147264"></a>
        <h2>See also</h2>
        <p>
      <a class="link" href="insglobal.html" title="insglobal"><em class="citetitle">insglobal</em></a>, <a class="link" href="insremot.html" title="insremot"><em class="citetitle">insremot</em></a>, <a class="link" href="midglobal.html" title="midglobal"><em class="citetitle">midglobal</em></a>, <a class="link" href="remoteport.html" title="remoteport"><em class="citetitle">remoteport</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp125152160"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Simon Schampijer</td>
          </tr>
          <tr>
            <td>2006</td>
          </tr>
        </table>
        <p>
    </p>
        <p>
      New in version 5.03
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="miditempo.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="min.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">miditempo </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> min</td>
        </tr>
      </table>
    </div>
  </body>
</html>
